package com.zznj.xzjc.net.rxjava;


import com.zznj.xzjc.net.entity.BaseBean;

/**
 * Created by liukun on 16/3/10.
 */
public class ApiException extends RuntimeException {

    public static final int USER_NOT_EXIST = 100;
    public static final int WRONG_PASSWORD = 101;

    public ApiException(BaseBean bb) {
        this(getApiExceptionMessage(bb));
    }

    public ApiException(String detailMessage) {
        super(detailMessage);
    }

    /**
     * 由于服务器传递过来的错误信息直接给用户看的话，用户未必能够理解
     * 需要根据错误码对错误信息进行一个转换，在显示给用户
     * @param bb
     * @return
     */
    private static String getApiExceptionMessage(BaseBean bb){
        return bb.getMessage();
    }
}

